import EventRoute from './EventRoute'

const configs = import.meta.glob('./modules/*.ts')
const modules = Object.keys(configs).map((pathname) => configs[pathname]())

export default async function getRoutes(): Promise<EventRoute[]> {
  const moduleWithDefault = (await Promise.all(modules)) as { default: EventRoute[] }[]
  return moduleWithDefault.map((module) => module.default).flat()
}
